package seven.servlet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import seven.service.AdminService;
import seven.service.GoodsService;
import seven.service.UserService;
import seven.service.UserServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//这里先用类直接注册的方式使用注解
//这个是运行类？其子类要添加component注解


 @Component
public class UserServlet extends HttpServlet {
    @Autowired
    public UserService userService;
    public UserService userService2;
    @Autowired
    public GoodsService goodsService;

    @Autowired
    public AdminService adminService;
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.getWriter().println(userService);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp){

    }


    UserServlet(UserService userService){
        this.userService2=userService;
    }

    //这里要写一个从容器中取东西的变量
    public UserService getUser(){
        return userService;
    }
}
